package jircbot;

import java.util.ArrayList;
import jircbot.irc.Irc;
import jircbot.irc.IrcObserver;
import jircbot.irc.IrcServerMessage;

/**
 *
 * @author matt
 */
class PluginHandler implements IrcObserver {
	private ArrayList <Plugin> plugins;
	private Irc irc;

	PluginHandler(Irc irc)
	{
		plugins = new ArrayList();
		this.irc = irc;
	}

	void addPlugin(Plugin plugin)
	{
		plugins.add(plugin);
	}

	void removePlugin(Plugin plugin)
	{
		plugins.remove(plugin);
	}

	public void serverMessageReceived(IrcServerMessage message)
	{
		if (!plugins.isEmpty())
		{
			for (int i = 0; i < plugins.size(); i++)
			{
				plugins.get(i).serverMessageReceived(message);
			}
		}
	}
}
